<<<<<<< HEAD
import request from '@/utils/request'

// 登录
export function login(data) {
  return request({
    url: '/auth/login',
    method: 'post',
    data: {
      username: data.username,
      password: data.password
    }
=======
import request, { post, get } from '@/utils/request'

// 登录
export function login(data) {
  return post('/auth/login', data, {
    showLoading: true,
    loadingText: '登录中...'
>>>>>>> c61637f (所有前后端正常登录)
  })
}

// 注册
export function register(data) {
<<<<<<< HEAD
  return request({
    url: '/auth/register',
    method: 'post',
    data
=======
  return post('/auth/register', data, {
    showLoading: true,
    loadingText: '注册中...'
  })
}

// 获取验证码图片
export function getCaptcha() {
  return get('/auth/captcha', {}, {
    showLoading: false
>>>>>>> c61637f (所有前后端正常登录)
  })
}

// 发送验证码
export function sendVerifyCode(data) {
<<<<<<< HEAD
  return request({
    url: '/auth/verify-code',
    method: 'post',
    data
  })
}

// 重置密码
export function resetPassword(data) {
  return request({
    url: '/auth/reset-password',
    method: 'post',
    data
=======
  return post('/auth/verify-code', data, {
    showLoading: true,
    loadingText: '发送中...'
  })
}

// 发送短信验证码（兼容新版本）
export function sendSmsCode(data) {
  return sendVerifyCode(data)
}

// 重置密码
export function resetPassword(data) {
  return post('/auth/reset-password', data, {
    showLoading: true,
    loadingText: '重置中...'
>>>>>>> c61637f (所有前后端正常登录)
  })
}

// 修改密码
export function changePassword(data) {
  return request({
    url: '/auth/password',
    method: 'put',
<<<<<<< HEAD
    data
=======
    data,
    showLoading: true,
    loadingText: '修改中...'
>>>>>>> c61637f (所有前后端正常登录)
  })
}

// 获取用户信息
export function getUserInfo() {
<<<<<<< HEAD
  return request({
    url: '/auth/info',
    method: 'get'
=======
  return get('/auth/info', {}, {
    showLoading: false
>>>>>>> c61637f (所有前后端正常登录)
  })
}

// 刷新token
export function refreshToken() {
<<<<<<< HEAD
  return request({
    url: '/auth/refresh-token',
    method: 'post'
=======
  return post('/auth/refresh-token', {}, {
    showLoading: false,
    showError: false
>>>>>>> c61637f (所有前后端正常登录)
  })
}

// 退出登录
export function logout() {
<<<<<<< HEAD
  return request({
    url: '/auth/logout',
    method: 'post'
=======
  return post('/auth/logout', {}, {
    showLoading: false,
    showError: false
>>>>>>> c61637f (所有前后端正常登录)
  })
}

// 第三方登录
export function socialLogin(type) {
  return request({
    url: `/auth/social-login/${type}`,
    method: 'post'
  })
}

// 获取第三方登录URL
export function getSocialLoginUrl(type) {
  return request({
    url: `/auth/social-login/${type}/url`,
    method: 'get'
  })
}

// 第三方登录回调
export function socialLoginCallback(type, code) {
<<<<<<< HEAD
  return request({
    url: `/auth/social-login/${type}/callback`,
    method: 'get',
    params: { code }
=======
  return get(`/auth/social-login/${type}/callback`, { code }, {
    showLoading: true,
    loadingText: '登录中...'
  })
}

// 上传文件
export function uploadFile(file, config = {}) {
  const formData = new FormData()
  formData.append('file', file)

  return post('/upload', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    showLoading: true,
    loadingText: '上传中...',
    timeout: 60000,
    ...config
  })
}

// 检查用户名是否可用
export function checkUsername(username) {
  return get('/auth/check-username', { username }, {
    showLoading: false,
    showError: false
  })
}

// 检查手机号是否已注册
export function checkPhone(phone) {
  return get('/auth/check-phone', { phone }, {
    showLoading: false,
    showError: false
  })
}

// 检查邮箱是否已注册
export function checkEmail(email) {
  return get('/auth/check-email', { email }, {
    showLoading: false,
    showError: false
  })
}

// 获取地区数据
export function getRegions(parentId = 0) {
  return get('/common/regions', { parentId }, {
    showLoading: false
  })
}

// 获取服务类型列表
export function getServiceTypes() {
  return get('/common/service-types', {}, {
    showLoading: false
  })
}

// 实名认证
export function realNameAuth(data) {
  return post('/auth/real-name-auth', data, {
    showLoading: true,
    loadingText: '认证中...'
  })
}

// 商家资质认证
export function merchantAuth(data) {
  return post('/auth/merchant-auth', data, {
    showLoading: true,
    loadingText: '提交认证...'
  })
}

// 获取商家认证状态
export function getMerchantAuthStatus() {
  return get('/auth/merchant-auth-status', {}, {
    showLoading: false
  })
}

// 更新用户信息
export function updateUserInfo(data) {
  return post('/auth/update-user-info', data, {
    showLoading: true,
    loadingText: '更新中...'
  })
}

// 绑定手机号
export function bindPhone(data) {
  return post('/auth/bind-phone', data, {
    showLoading: true,
    loadingText: '绑定中...'
  })
}

// 绑定邮箱
export function bindEmail(data) {
  return post('/auth/bind-email', data, {
    showLoading: true,
    loadingText: '绑定中...'
>>>>>>> c61637f (所有前后端正常登录)
  })
}